<?php

namespace plugins\user_other;

use cmf\lib\Plugin;
use think\Db;


class UserOtherPlugin extends Plugin
{
    public $info = [
        'name'        => 'UserOther',
        'title'       => '用户管理',
        'description' => '用户管理',
        'status'      => 1,
        'version'     => '1.0',
        'author' => 'fanchao'
    ];
    public $hasAdmin = 0; //插件是否有后台管理界面

    // 插件安装 
    public function install()
    {
        return true;
    }

    // 插件卸载
    public function uninstall()
    {
        return true;
    }

    //显示会员新增列表等等~~
    public function adminDashboard()
    {
        //总用户数据
        //今日新增用户
        //7日数据汇总
        $data['all'] = Db::name('user')->count();
        $data['today'] = Db::name('user')->whereTime('create_time','today')->count();
        $data['score'] = Db::name('user')->sum('score');
        $data['balance'] = Db::name('user')->sum('balance');
        $this->assign('data', $data);
        return [
            'width'  => 12,
            'view'   => $this->fetch('user_box'),
            'plugin' => 'UserOther'
        ];

    }

}
